<div id="a">
  <span>1</span>
  <p>2</p>
  <a href="">3</a>
  <div>4</div>
</div>

<script>
  let element = document.getElementById('a');

  function reverseChild(element) {
    let children = Array.prototype.slice.call(element.childNode);
    for(let child of children){
      element.removeChild(child);
    }
    children.reverse();
    for(let child of children){
      element.appendChild(child);
    }
  }

  reverseChild(element);
</script>